<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'header.php'?>
	<link rel="stylesheet" href="<?=$staticAdminUrl?>assets/css/workflow.css" />
	<div class="page-header">
		<h1><?=$workflowInfo['workflow_title']?> 表单设计器</h1>
	</div>

	<div class="row">
		<div class="col-sm-10">
			<div class="widget-box transparent">
				<div class="widget-header">
					<h4>表单设计器（请拖动右侧表单项到设计器内）</h4>
				</div>
				<form id="workflow-design-form" class="form-horizontal">
					<div class="workflow-design-form-bottom"></div>
				</form>
			</div>
		</div>
		<div class="col-sm-2">
			<div class="widget-box transparent">
				<div class="widget-header">
					<h4>可用表单项（长按拖动）</h4>
				</div>
				<div class="widget-body">
					<div class="widget-main no-padding">
						<div id="workflow-item"></div>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'footer.php'?>
<!-- 百度编辑器 -->
<script src="<?=$staticAdminUrl?>assets/ueditor/ueditor.config.js"></script>
<script src="<?=$staticAdminUrl?>assets/ueditor/ueditor.all.js"></script>
<!-- 表单js -->
<script src="<?=$staticAdminUrl?>assets/js/workflow.js"></script>
<script type="text/javascript">
	
	$(function(){
		// 初始化表单内容
		$(document).workflowFormDesign({
			"draggableDom": $("#workflow-item"),
			"droppableDom": $("#workflow-design-form"),
			"formData": <?=$workflowInfo['workflow_form'] ? $workflowInfo['workflow_form'] : "null"?>,
			"callback": function(formData){
				// 保存表单结构
				var actionUrl = "<?=admin_url('workflow/save_workflow_form')?>";
				var params = {
					"workflow": "<?=$workflowInfo['id']?>",
					"workflow_form": formData
				};
				ajax_post(actionUrl, params, function(res) {
					window.location.href = "<?=admin_url('workflow/process')?>";
				})
			}
		})
	})
</script>